package com.sea.finance.service.impl;


import com.sea.finance.entity.RefusedTax;
import com.sea.finance.entity.RefusedTaxRecord;
import com.sea.finance.mapper.RefusedTaxMapper;
import com.sea.finance.mapper.RefusedTaxRecordMapper;
import com.sea.finance.service.RefusedTaxRecordService;
import com.sea.finance.service.RefusedTaxService;
import com.sea.physical.service.CreatePlanService;
import com.sea.supply.service.ProduceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * @author 陈鸿飞
 */
@Service
public class RefusedTaxRecordServiceImpl implements RefusedTaxRecordService {

    @Autowired
    private RefusedTaxRecordMapper refusedTaxRecordMapper;
    @Autowired
    private RefusedTaxService refusedTaxService;


    @Override
    public List<RefusedTaxRecord> findByCreatePlanNo(String createPlanNo) {
        return refusedTaxRecordMapper.findByCreatePlanNo(createPlanNo);
    }

    @Override
    public int save(RefusedTaxRecord refusedTaxRecord) {
        deleteByCreatePlanNo(refusedTaxRecord.getCreatePlanNo());
        if(refusedTaxRecord.getFlag().equals(1)){
            refusedTaxService.updateRefusedStatus(refusedTaxRecord.getCreatePlanNo());
        }
        return refusedTaxRecordMapper.insert(refusedTaxRecord);
    }

    @Override
    public Integer deleteByCreatePlanNo(String createPlanNo) {
        return refusedTaxRecordMapper.deleteByCreatePlanNo(createPlanNo);
    }
}
